<template>
	<view class="wrapper">
		<carousel :options="banners" />
		<view class="actions-box">
			<!-- 客服 -->
			<button class="button-kefu" open-type="im" :data-im-id="gameDetail.doyinImId">
				<image :src="kefuSrc" mode="aspectFit" style="width: 100%; height: 100%">
				</image>
			</button>
			<!-- 关注 -->
			<button class="button-guanzhu" @click="fllowUser">
				<image :src="guanzhuSrc" mode="aspectFit" style="width: 100%; height: 100%">
				</image>
			</button>
		</view>
	</view>
</template>

<script>
	// 引用组件
	import tpl_banner from "@/pages/tabbar/home/template/tpl_banner"; //导航栏模块
	import storage from "@/utils/storage.js";
	import {
		getBannerList
	} from "@/api/goods.js"

	export default {
		data() {
			return {
				banners: [], //轮播图数据
				gameDetail: storage.getGameDetail(),
				kefuSrc: 'https://cdn.osisx.com/game/image/e78bb28b1ffb4eb1bff9dedd39567474.png',
				guanzhuSrc: 'https://cdn.osisx.com/game/image/e62d621adfd84d7c99854f4b89791f8b.png',
			};
		},
		components: {
			carousel: tpl_banner,

		},

		mounted() {
			this.init();
		},
		methods: {
			/**
			 * 实例化首页数据楼层
			 */
			init() {
				if (this.banners.length > 0) {
					return
				}
				getBannerList().then((res) => {
					this.banners = res.data.result
				}).catch(err => {
					uni.$on("silentSuccess", (msg) => {
						this.init()
					});
				})
			},
			// 关注
			fllowUser() {
				tt.followAwemeUser({
					awemeId: this.gameDetail.doyinImId
				})
			},
		},
	};
</script>

<style scoped lang="scss">
	.wrapper {
		height: 100vh;
		padding-top: 214rpx;
		background: transparent;
		background: linear-gradient(to bottom, #96E9FB, #ECADCF, #ECADCF, #F1F2F6, #96E9FB, #F0F2F6) no-repeat;
	}

	.button-kefu {
		position: absolute;
		left: 50rpx;
		bottom: 48rpx;
		width: 44rpx;
		height: 90rpx;
		border: none;
		padding: 0;
		margin: 0;
		background: transparent;

		&::after {
			display: none;
			background: transparent;
		}
	}

	.button-guanzhu {
		position: absolute;
		left: 174rpx;
		bottom: 48rpx;
		width: 44rpx;
		height: 90rpx;
		border: none;
		padding: 0;
		margin: 0;
		background: transparent;

		&::after {
			background: transparent;
			display: none;
		}
	}
</style>